<!-- 资产新增 -->

<template>
  <div>
    <EasyRow col2>
      <FormInput :label="`${one.name}单号`" bind="recordCode" disabled required />
      <FormSelect
        :label="`${one.name}仓库`"
        bind="warehouseId, warehouseName, warehouseCode"
        :dict="warehouse_selectDict"
        required
      />
    </EasyRow>

    <EasyRow col2>
      <FormDate :label="`${one.name}时间`" bind="recordTime" string required />
      <FormSelect
        :label="`${one.name}类型`"
        bind="recordTypeId, recordTypeName, recordTypeCode"
        :dict="one.category === 1 ? CORE.DICT.stock_out_type : CORE.DICT.stock_in_type"
        required
      />
    </EasyRow>

    <FormTree
      v-if="one.category === 1"
      :label="`领用${CORE.MAP.ORGAN}`"
      bind="organId, organName"
      :dict="CORE.ORGAN.DICT"
    />

    <FormTextarea label="备注信息" bind="description" :rows="2" :max="50" />

    <div class="SpareStock-record-info-addBtn">
      <BtnAdd
        title="添加明細"
        :onClick="one.category === 1 ? openStock : backup_openEdit"
        :disabled="one.category === 1 && !one.warehouseId"
        icon=""
        small
      />
    </div>

    <SpareAddList />
  </div>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'BackupAdd',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [
    CORE.mixWeb(),
    CORE.mixWeb('backup', 'backup_'),
    CORE.mixWeb('stock', 'stock_'),
    CORE.mixSelect('warehouse', 'warehouse_'),
  ],

  /**
   * 组件导入 (Abc.vue + Abc/index.vue)
   */
  ...CORE.components(require.context('./', true, /vue$/)),

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 打开库存弹窗
     */
    async openStock() {
      const { stock_param, one, stock_startList, stock_openEdit } = this
      stock_param.warehouseId = [one.warehouseId]
      stock_startList()
      stock_openEdit()
    },
  },
}
</script>
